package org.autumn.thread;

import java.util.concurrent.TimeUnit;

public class DeamonMethod {
    public static void main(String[] args) {
        // 守护线程
        Thread daemon = new Thread(() -> {
            while (true) {
                if (Thread.currentThread().isInterrupted()) {
                    break;
                }
                try {
                    TimeUnit.SECONDS.sleep(1);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("daemon ....");
            }
        }, "daemon");
//        daemon.setDaemon(true);
        daemon.start();

        System.out.println("end");

    }
}
